package uit.bus;

import java.util.ArrayList;

import android.content.Context;
import android.graphics.drawable.Drawable;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.ItemizedOverlay;
import com.google.android.maps.MapView;
import com.google.android.maps.OverlayItem;

public class MyItemizedOverlay extends ItemizedOverlay<OverlayItem> {

	private ArrayList<OverlayItem> myOverlays;
	public Context context;

	public MyItemizedOverlay(Drawable defaultMarker, Context context) {
		super(boundCenterBottom(defaultMarker));
		// super(defaultMarker);
		this.context = context;
		myOverlays = new ArrayList<OverlayItem>();
		populate();
	}

	public void addOverlay(OverlayItem overlay) {
		myOverlays.add(overlay);
		populate();
	}

	@Override
	protected OverlayItem createItem(int i) {
		return myOverlays.get(i);
	}

	// Removes overlay item i
	public void removeItem(int i) {
		if (i >= 0)
			myOverlays.remove(i);
		populate();
	}

	public void removeAll() {
		myOverlays.clear();
		populate();
	}

	// Returns present number of items in list
	@Override
	public int size() {
		return myOverlays.size();
	}

	@Override
	public boolean onTap(GeoPoint p, MapView mapView) {
		// TODO Auto-generated method stub
		return true;
	}

	@Override
	protected boolean onTap(int index) {
		// TODO Auto-generated method stub
		return true;
	}
	
	
}
